import axios from "axios";
import { message } from "ant-design-vue";


/**
 * 配置
 * @type {AxiosInstance}
 */
const service = axios.create({
    timeout: 0, //不限时
});


/**
 * 请求头  设置  设置token， 'Content-Type': 'application/x-www-form-urlencoded'  等
 */
service.interceptors.request.use((config) => {
  let cookie = 'JSESSIONID=52BD2D1609515CC49D2E53D15EEADF19;';

  if(cookie) {
    // config.headers['Cookie'] = cookie;
      config.headers['Content-Type'] = 'application/x-www-form-urlencoded';
  }

  return config;

},
    (error) => {
        return error;
    });


/**
 * 响应
 */
service.interceptors.response.use((response) => {
    const res = response.data;

    return res;

},
    (error) => {
        message.error(error);
        return error;
    });


export default service;

